package cn.gogetter;

import weka.core.Instances;
import weka.experiment.InstanceQuery;

public class LoadFromDB {
	public static void main(String[] args){
		InstanceQuery query = null;
		Instances data = null;
		try {
			query = new InstanceQuery();
			query.setDatabaseURL("jdbc:mysql://192.168.111.130:3306/weka");
			query.setUsername("root");
			query.setPassword("root");
			query.setQuery("select * from weather");
			data = query.retrieveInstances();
			if(data.classIndex() == -1){
				data.setClassIndex(data.numAttributes() -1);
			}
			System.out.println(data);
			System.out.println("加载完成============================================");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
